#include <iostream>
#include <string>
using namespace std;

int q;
string s;

int main()
{
    cin >> q;

    while (q--)
    {
        cin >> s;

        int n = s.size();
        bool flag = false;
        for (int i = n - 1; i > -1; i--)
        {
            if ((s[i] - '0') % 2 == 0)
            {
                swap(s[i], s[n - 1]);
                flag = true;
                break;
            }
        }

        cout << (flag ? s : "-1") << endl;
    }

    return 0;
}
